package service.factory;

import library.service.Book;

public class SpecialBookImpl implements Book {

	private String name;
	private String category;

	public SpecialBookImpl(String name, String category) {
		this.name = name;
		this.category = category;
	}

	public SpecialBookImpl() {
		name = "East of Eden";
		category = "fiction";
	}

	public String getName() {
		return name;
	}

	public String getCategory() {
		return category;
	}

	public int compareTo(Object object) {
		if (object == null || !(object instanceof Book)) {
			throw new IllegalArgumentException(
					"Incorrect object for comparison");
		}

		Book book = (Book) object;
		int bookNameComparison = getName().compareTo(book.getName());
		if (bookNameComparison != 0) {
			return getCategory().compareTo(book.getCategory());
		} else {
			return bookNameComparison;
		}
	}

	public Book getBook() {
		return this;
	}

	public void setName(String newBookName) {
		name = newBookName;
	}
}
